home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v7n12.arc / RENAME.PAS < prev    next >
Pascal/Delphi Source File  |  1988-06-21  |  2KB  |  51 lines

  1. PROGRAM Rename_with_space;
  2.  
  3. { NOTE: This is a Turbo Pascal 4.0 program, but you can convert
  4.   it for TP3 easily enough.  There are two places you have to
  5.   change, both marked with "(*TP3*)".  Look for that marker and
  6.   follow the instructions.}
  7.  
  8. (*TP3*)(*Delete the next two lines for use with TP3*)
  9. {$R-,S-,I-,D-,T-,F-,V-,B-,N-}
  10. {$M 1024,0,0 }
  11. TYPE
  12.   commandstr = STRING[127];
  13. VAR
  14.   commandLine,
  15.   oldname, newname : commandstr;
  16.   pstart, pend     : Byte;
  17.   F                : FILE;
  18.  
  19.   PROCEDURE Error_Out;
  20.   BEGIN
  21.     WriteLn('SYNTAX: RENDIR "oldname" "newname"');
  22.     WriteLn('The quotes around the two names are REQUIRED.');
  23.     Halt;
  24.   END;
  25.  
  26. BEGIN
  27.   commandline := commandStr(Ptr(PrefixSeg, $80)^);
  28.   (*TP3*)(*To use with TP3, comment out the line above and
  29.            UN-comment out the line below*)
  30. (*  Move(MEM[CSeg:$80], commandline, 128);*)
  31.   pstart := Pos('"', commandline);  IF pstart = 0 THEN error_Out;
  32.   commandline[pstart] := ' ';
  33.   pend := Pos('"', commandline);    IF pend = 0 THEN error_Out;
  34.   commandline[pend] := ' ';
  35.   (*The old name is the text between the first pair of "s*)
  36.   oldname := Copy(commandline, Succ(pstart), Pred(pend-pstart));
  37.   pstart := Pos('"', commandline);  IF pstart = 0 THEN error_Out;
  38.   commandline[pstart] := ' ';
  39.   pend := Pos('"', commandline);    IF pend = 0 THEN error_Out;
  40.   commandline[pend] := ' ';
  41.   (*The new name is the text between the second pair of "s*)
  42.   newname := Copy(commandline, Succ(pstart), Pred(pend-pstart));
  43.   Assign(F, oldname);
  44.   Rename(F, newname);
  45.   IF IOResult = 0 THEN
  46.     WriteLn('Successfully renamed "', oldname, '" to "', newname, '"')
  47.   ELSE
  48.     WriteLn('Unable to rename "', oldname, '" to "', newname, '"');
  49. END.
  50.  
  51.